{extend name="public/base" /}
{block name="main"}

<style>
    .nw{ width: 180px; float:left;}
</style>
<article class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
		<span class="l">
			<a href="{:url('code/addField',$get)}"  class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加字段</a>
		</span>
    </div>

    <form action="" method="post" class="form form-horizontal" id="form-save" >
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3" style="width: 150px;"><span class="c-red">*</span>字段管理：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <table class="table table-border table-bg table-bordered">
                    <thead>
                    <tr class="text-c">
                        <th>字段名称</th>
                        <th>字段类型</th>
                        <th>是否为空</th>
                        <th>默认值</th>
                        <th>列表显示</th>
                    </tr>
                    </thead>
                    <?php foreach($file_desc as $v){ ?>
                    <tr class="text-c active">
                        <td><?php echo $v['Field']?></td>
                        <td><?php echo $v['Type']?></td>
                        <td><?php echo $v['Null']?></td>
                        <td><?php echo $v['Default']?></td>
                        <td>
                            <input type="radio" name="list[<?php echo $v['Field']?>]" checked value="on"> 是
                            <input type="radio" name="list[<?php echo $v['Field']?>]" value="off"> 否
                        </td>
                    </tr>
                    <?php } ?>
                </table>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"></label>
            <div class="formControls col-xs-8 col-sm-9">
                <h5 style="color: red">说明：你需要添加新字段才能生成{后台前端表单}....so.....快来添加该表单需要的字段吧！</span></h5>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3" style="width: 150px;"><span class="c-red">*</span>表单HTML：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <textarea style="width: 100%; min-height: 200px" name="form_html"><?php foreach($field_form_html as $v){echo htmlspecialchars($v['table_form_html']); } ?></textarea>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3" style="width: 150px;"><span class="c-red">*</span>列表配置：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <table class="table table-border table-bg table-bordered">
                    <thead>
                    <tr class="text-c">
                        <th>修改</th>
                        <th>删除</th>
                        <th>批量删除</th>
                    </tr>
                    </thead>
                    <tr class="text-c active">
                        <td>
                            <input type="radio" name="is_edit" value="on" checked>  是
                            <input type="radio" name="is_edit" value="off"> 否
                        </td>
                        <td>
                            <input type="radio" name="is_del" value="on" checked>  是
                            <input type="radio" name="is_del" value="off"> 否
                        </td>
                        <td>
                            <input type="radio" name="more_del" value="on" checked>  是
                            <input type="radio" name="more_del" value="off"> 否
                        </td>
                    </tr>
                </table>
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input type="hidden" value="<?php echo $get['table_name']?>" name="table_name">
                <input type="hidden" value="<?php echo $get['controller_name']?>" name="controller_name">
                <button  class="btn btn-success radius" type="submit"><i class="icon-ok"></i> 确认</button>
            </div>
        </div>
    </form>


</article>



{/block}
{block name="js"}
<script>
    function admin_add(title,url,w,h){
        layer_show(title,url,w,h);
    }

    $("#form-save").validate({
        rules:{
            form_html:{
                required:true,
            }
        },
        submitHandler:function(form){
            /**
             * 成功之后的回调函数
             * @type {{success: options.success}}
             */
            var options = {
                success: function (data) {
                    if(data.code==10000){
                        layer.msg(data.msg,{icon:1,time:1000});
                        setInterval("closeWindow()",1200);
                    }else{
                        layer.msg(data.msg,{icon:5,time:1000});
                    }
                }
            };
            $(form).ajaxSubmit(options);
        }
    });
    function closeWindow(){
        window.parent.location.reload();
    }
</script>
{/block}